<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Get the size of an image from a string</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.getimagesize.html">getimagesize</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.image-type-to-extension.html">image_type_to_extension</a></div>
 <div class="up"><a href="ref.image.html">GD and Image 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.getimagesizefromstring" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">getimagesizefromstring</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.4.0)</p><p class="refpurpose"><span class="refname">getimagesizefromstring</span> &mdash; <span class="dc-title">Get the size of an image from a string</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.getimagesizefromstring-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">array</span> <span class="methodname"><strong>getimagesizefromstring</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$imagedata</code></span>
   [, <span class="methodparam"><span class="type">array</span> <code class="parameter reference">&$imageinfo</code></span>
  ] )</div>

  <p class="para rdfs-comment">
   Identical to <span class="function"><a href="function.getimagesize.html" class="function">getimagesize()</a></span> except that <span class="function"><strong>getimagesizefromstring()</strong></span>
   accepts a string instead of a file name as the first parameter.
  </p>
  <p class="para">
   See the <span class="function"><a href="function.getimagesize.html" class="function">getimagesize()</a></span> documentation for details on how this
   function works.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.getimagesizefromstring-parameters">
  <h3 class="title">参数</h3>
  <dl>

   
    <dt>
<em><code class="parameter">imagedata</code></em></dt>

    <dd>

     <p class="para">
      The image data, as a string.
     </p>
    </dd>

   
   
    <dt>
<em><code class="parameter">imageinfo</code></em></dt>

    <dd>

     <p class="para">
      See <span class="function"><a href="function.getimagesize.html" class="function">getimagesize()</a></span>.
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.getimagesizefromstring-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   See <span class="function"><a href="function.getimagesize.html" class="function">getimagesize()</a></span>.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.getimagesizefromstring-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-3113">
    <p><strong>Example #1 <span class="function"><strong>getimagesizefromstring()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$img&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'/path/to/test.png'</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//&nbsp;Open&nbsp;as&nbsp;a&nbsp;file<br /></span><span style="color: #0000BB">$size_info1&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">getimagesize</span><span style="color: #007700">(</span><span style="color: #0000BB">$img</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Or&nbsp;open&nbsp;as&nbsp;a&nbsp;string<br /></span><span style="color: #0000BB">$data&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">file_get_contents</span><span style="color: #007700">(</span><span style="color: #0000BB">$img</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$size_info2&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">getimagesizefromstring</span><span style="color: #007700">(</span><span style="color: #0000BB">$data</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.getimagesizefromstring-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.getimagesize.html" class="function" rel="rdfs-seeAlso">getimagesize()</a> - 取得图像大小</span></li>
   </ul>
  </p>
 </div>

 
</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.getimagesize.html">getimagesize</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.image-type-to-extension.html">image_type_to_extension</a></div>
 <div class="up"><a href="ref.image.html">GD and Image 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
